# Definition for singly-linked list.
class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None


class Solution:
    def isPalindrome(self, head: ListNode) -> bool:
        # if not head:
        #     return True
        mid_list = []
        while head:
            mid_list.append(head.val)
            head = head.next
        length = len(mid_list)
        return mid_list[:length // 2] == mid_list[:(length - 1) // 2:-1]


a = Solution()
print(a.isPalindrome(None))
